<template>
  <view class="selectDepartment" :style="{height: `${windowHeight}px`}">
	<view class="hospitalName">
		{{hospitalName}}
	</view>
	<view class="deptList" v-if="deptList.length>0">
		<view class="deptRight" style="height: calc(100vh - 5rem);">
			<view class="rightText" v-for="(item,index) in deptList" :key="index">
				<view class="flex-1">
					{{item.deptName}}
				</view>
				<u-button :disabled="item.disbal" type="primary" shape="circle" :plain="true" size="mini" text="去挂号" @click="goDeptRegistration(item)" style="width:120rpx;padding: 24rpx 0"></u-button>
			</view>
		</view>
		<view class="tishi">
			温馨提示：以上推荐科室仅供参考
		</view>
	</view>
	<view class="noCard" v-else>
		<view class="images">
			<img src="@/static/images/noCard.png" alt="">
			<view>
				暂无推荐科室
			</view>
		</view>
		
	</view>
  </view>
</template>

<script>
	import { deptInfoHisWard,deptInfoList } from '@/api/system/public'
  export default {
    data() {
      return {
        windowHeight: uni.getSystemInfoSync().windowHeight,
		srchVal:'',
		hostoryList:[],
		avtiveIndex:0,
		wardList:[],
		deptList:[],
		hospitalName:'',
		thirdDeptCode:'',
      }
    },
	onLoad(options) {
		this.thirdDeptCode = options.thirdDeptCode
		if(uni.getStorageSync('hospital')){
			this.getDeptList(this.thirdDeptCode)
		}
		this.hospitalName = JSON.parse(uni.getStorageSync('hospital')).name
	},
    methods: {
      doSearch(){
		  if(this.hostoryList.indexOf(this.srchVal)==-1){
			  this.hostoryList.push(this.srchVal)
			  uni.setStorageSync('hostoryList', JSON.stringify(this.hostoryList))
		  }
		  
	  },
	  getDeptList(code){
		  // deptInfoList({hospitalCode:JSON.parse(uni.getStorageSync('hospital')).hospitalCode,deptCode:code}).then(res=>{
		  deptInfoList({hospitalCode:'0001',deptCode:code}).then(res=>{
			  this.deptList = res.rows
		  })
	  },
	  goDeptRegistration(item){
		  uni.navigateTo({
		  	url: '/pages/home/deptRegistration?deptCode=' + item.deptCode + '&wardCode=' + item.wardCode +
		  		'&registerType=1'
		  })
	  }
    }
  }
</script>

<style lang="scss" scoped>
  page {
    background-color: #fff;
  }
  .hospitalName{
	  width: 100%;
	  text-align: center;
	  color: #666666;
	  margin: 1rem 0;
  }
  .noCard{
		width: 100%;
		text-align: center;
		color: #666666;
		.images{
			width: 100%;
			margin-bottom: 20px;
			color: #666666;
			img{
				width: 55%;
				text-align: center;
			}
		}
		
	}
  .deptList{
	  font-size: 1rem;
	  .deptRight{
	  	width: 100%;
		overflow-y: auto;
		.rightText{
			padding: 20rpx;
			border-bottom:1px solid #f5f5f5;
			overflow: hidden;
			text-overflow:ellipsis;
			white-space: nowrap;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
	  }
	  .tishi{
		  text-align: center;
		  color: red;
		  width: 100%;
	  }
  }
  .srchWrap{
	  width: 100%;
	  position: relative;
	  margin-top: 0.5rem;
	  .seekAdviceFrom{
		  color: #1677FF;
		  position: absolute;
		  right: 12%;
		  top: 0.6rem;
		  font-size: 0.8rem;
	  }
	  .u-input{
		  width: 85%;
		  margin: 0 auto;
		  border-radius: 20px;
		  padding-left: 20px;
		  font-size: 0.8rem;
		  border-width: 1px;
	  }
  }
  .hostoryList{
	  display: flex;
	  flex-wrap: nowrap;
	  overflow-x: auto;
	  padding: 10px;
	  .hostoryItem{
		  font-size: 0.7rem;
		  padding: 2px 10px;
		  background: #f5f5f5;
		  font-size: #666;
		  border-radius: 10px;
		  margin-right: 10px;
		  white-space:nowrap;
	  }
  }
</style>
